/**
 * JAVACC DEMO 1.0
 * @copy right dwusoft company All rights reserved. 
 * @Package com.apache.svm.funds.service.plugins  
 */
package com.apache.funds.service.plugins;

import com.apache.api.manager.PluginConnector;
import com.apache.api.vo.ParamsVo;
import com.apache.api.vo.ResultEntity;
import com.apache.funds.manager.SvmVoucherManager;
import com.apache.funds.util.Prompt;

/**
 * 本类主要涉及业务逻辑<br>
 * 1.冻结（目前不推荐使用，建议后续使用FundsPublicOperatePlugin走模板统一处理）
 * @author Administrator
 *
 */
public class FundsFrozenPlugin implements PluginConnector {

	private SvmVoucherManager svmVoucherManager;

	public void setSptsVoucherManager(SvmVoucherManager svmVoucherManager) {
		this.svmVoucherManager = svmVoucherManager;
	}

	/**
	 * TODO 简单描述该方法的实现功能（可选）.  
	 * @see com.apache.api.manager.PluginConnector#execute(com.apache.api.vo.ParamsVo)  
	 */
	@Override
	public Object execute(ParamsVo vo) throws Exception {
		String voucherId = svmVoucherManager.saveInfo(vo);
		return this.buildResut(voucherId);
	}

	/**
	 * 对计算结果进行封装
	 * description:  
	 * @param storageId
	 * @return  
	 * @author goldocean 
	 * @update 2014-11-17
	 */
	private ResultEntity buildResut(String storageId) {
		ResultEntity re = new ResultEntity();
		if (storageId == null) {
			re.setMessage(Prompt.FAIL);
			re.setResult("true");
			re.setEntity("false");
		}
		String[] ary = storageId.split(",");
		if (ary[0].length() > 1) {
			re.setMessage(Prompt.SUCCESS);
			re.setResult("true");
			re.setEntity(ary[0]);
		} else {
			re.setMessage(ary[1]);
			re.setResult("true");
			re.setEntity("false");
		}
		return re;
	}

}
